import { Window } from "../../../component/window/Window";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SWedding } from "../../../../Message/Public/SWedding";
import { MarryHeartLock } from "./defin/MarryHeartLock";
import { Cache } from "../../cache/Cache";
import { SPublicMiniPlayer } from "../../../../Message/Public/SPublicMiniPlayer";
import { AvatarInfo } from "../../resource/info/AvatarInfo";
import { AvatarType } from "../../resource/info/AvatarType";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { GButton } from "../../../../com/mui/controls/GButton";
//class MarryMsgWindow
    
    export  class MarryMsgWindow extends Window
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(470, 229);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=new GTextFormat(FontUtil.songtiName, 14, 16777215);
            loc1.leading = 9;
            var loc2=new GTextFormat(FontUtil.songtiName, 12, 11661311);
            loc2.leading = 3;
            this._bg = new Object /* flash.display.Bitmap */();
            this.addChild(this._bg);
            LoaderManager.instance.load("MarryBg.png", this.onLoadComplete);
            this._bmpMan = new Object /* flash.display.Bitmap */();
            this._bmpMan.x = 123;
            this._bmpMan.y = 67;
            this.addChild(this._bmpMan);
            this._bmpWomen = new Object /* flash.display.Bitmap */();
            this._bmpWomen.x = 295;
            this._bmpWomen.y = 67;
            this.addChild(this._bmpWomen);
            var loc3=GlobalStyle.textFormat2;
            loc3.size = 14;
            loc3.align = flash.text.TextFormatAlign.CENTER;
            this._tfPlayerMan = ObjCreate.createTextField("", 100, 153, 90, 20, this, loc3);
            this._tfPlayerWomen = ObjCreate.createTextField("", 274, 153, 90, 20, this, loc3);
            this._tfAnd = ObjCreate.createTextField(Language.getString(43582), 224, 153, 20, 20, this);
            this._tfMarryNum = ObjCreate.createTextField("", 100, 178, 250, 20, this);
            this._tfMarryHeartLock = ObjCreate.createTextField("", 100, 200, 250, 20, this);
            ObjCreate.createTextField(Language.getString(43583), 100, 222, 250, 20, this);
            this._btnAskForInvite = ObjCreate.createGButton(Language.getString(43584), 115, 250, 70, 26, this, "LinkButton");
            this._btnBless = ObjCreate.createGButton(Language.getString(43585), 240, 250, 70, 26, this, "LinkButton");
            this._btnManagerGuest = ObjCreate.createGButton(Language.getString(43586), 115, 250, 70, 26, this, "LinkButton");
            this._btnLookGift = ObjCreate.createGButton(Language.getString(43587), 240, 250, 70, 26, this, "LinkButton");
            this._btnManagerGuest.visible = false;
            this._btnLookGift.visible = false;
            this._btnEnterMarryScene = ObjCreate.createGLoadedButton("MarryBtn", 120, 290, 230, 39, this);
            this._btnEnterMarryScene.label = Language.getString(43588);
            this.setMarryBtnStyle(this._btnEnterMarryScene);
            this._btnLeaveMarryScene = ObjCreate.createGLoadedButton("MarryBtn", 120, 290, 230, 39, this);
            this._btnLeaveMarryScene.label = Language.getString(43589);
            this.setMarryBtnStyle(this._btnLeaveMarryScene);
            this._btnLeaveMarryScene.visible = false;
            this._btnAskForInvite.addEventListener(flash.events.MouseEvent.CLICK, this.onAskForInvite);
            this._btnBless.addEventListener(flash.events.MouseEvent.CLICK, this.onBless);
            this._btnManagerGuest.addEventListener(flash.events.MouseEvent.CLICK, this.onManagerGuest);
            this._btnLookGift.addEventListener(flash.events.MouseEvent.CLICK, this.onLookGift);
            this._btnEnterMarryScene.addEventListener(flash.events.MouseEvent.CLICK, this.onEnterMarryScene);
            this._btnLeaveMarryScene.addEventListener(flash.events.MouseEvent.CLICK, this.onLeaveMarryScene);
            return;
        }

        /* internal  */setMarryBtnStyle(arg1: GLoadedButton): void
        {
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 11661308);
            var loc2=new GTextFormat(FontUtil.songtiName, 12, 15859633);
            arg1.setStyle("textFormat", loc1);
            arg1.setStyle("disabledTextFormat", loc2);
            return;
        }

        /* internal  */onAskForInvite(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryAskForInvite, this._wedding));
            this.hide();
            return;
        }

        /* internal  */onBless(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryShowBlessWindow, this._wedding));
            this.hide();
            return;
        }

        /* internal  */onManagerGuest(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryShowManageWindow, this._wedding));
            this.hide();
            return;
        }

        /* internal  */onLookGift(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryShowBlessWindow, this._wedding));
            this.hide();
            return;
        }

        /* internal  */onEnterMarryScene(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryEnterMarryScene, this._wedding));
            return;
        }

        /* internal  */onLeaveMarryScene(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CopyQuitCopy));
            this.hide();
            return;
        }

        public updateWedding(arg1: SWedding): void
        {
            this._wedding = arg1;
            this.updateHeadImage(arg1.man, arg1.woman);
            this._tfPlayerMan.text = arg1.man.name;
            this._tfPlayerWomen.text = arg1.woman.name;
            this._tfMarryNum.text = Language.getStringByParam(43596, arg1.marryCount.toString());
            this._tfMarryHeartLock.htmlText = Language.getStringByParam(43590, MarryHeartLock.getHeartLockHtml(arg1.weddingType));
            if (this.isSelfMarry(arg1)) 
            {
                this._btnManagerGuest.visible = true;
                this._btnLookGift.visible = true;
                this._btnAskForInvite.visible = false;
                this._btnBless.visible = false;
            }
            else 
            {
                this._btnManagerGuest.visible = false;
                this._btnLookGift.visible = false;
                this._btnAskForInvite.visible = true;
                this._btnBless.visible = true;
            }
            this._btnLeaveMarryScene.visible = Cache.instance.copy.isInWeddingCopy();
            this._btnEnterMarryScene.visible = Cache.instance.marry.isInCelebration && !this._btnLeaveMarryScene.visible;
            return;
        }

        /* internal  */isSelfMarry(arg1: SWedding): Boolean
        {
            var loc1=Cache.instance.role.entityInfo.entityId.id;
            return loc1 == arg1.man.entityId.id || loc1 == arg1.woman.entityId.id;
        }

        protected /* override */ updateBtnSize(): void
        {
            if (_closeBtn) 
            {
                _closeBtn.x = 385;
                _closeBtn.y = 46;
            }
            return;
        }

        /* internal  */updateHeadImage(arg1: SPublicMiniPlayer, arg2: SPublicMiniPlayer): void
        {
            var man: SPublicMiniPlayer;
            var woman: SPublicMiniPlayer;

            var loc1;
            man = arg1;
            woman = arg2;
            AvatarInfo.getAvatar(man.camp, man.sex, AvatarType.SMALL, (arg1: ImageInfo): void
            {
                _bmpMan.bitmapData = arg1.bitmapData;
                return;
            }, man.avatarId)
            AvatarInfo.getAvatar(woman.camp, woman.sex, AvatarType.SMALL, (arg1: ImageInfo): void
            {
                _bmpWomen.bitmapData = arg1.bitmapData;
                return;
            }, woman.avatarId)
            return;
        }

        /* internal  */onLoadComplete(arg1): void
        {
            this._bg.bitmapData = arg1.bitmapData as Object /* flash.display.BitmapData */;
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfPlayerMan: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfPlayerWomen: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfAnd: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfMarryNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfMarryHeartLock: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnAskForInvite: GButton;

        /* internal */ /* var */_btnBless: GButton;

        /* internal */ /* var */_btnManagerGuest: GButton;

        /* internal */ /* var */_btnLookGift: GButton;

        /* internal */ /* var */_btnEnterMarryScene: GLoadedButton;

        /* internal */ /* var */_btnLeaveMarryScene: GLoadedButton;

        /* internal */ /* var */_bmpMan: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpWomen: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_wedding: SWedding;
    }
